package com.soupinabox;

import com.soupinabox.events.EventBroker;

import javax.swing.*;
import java.awt.*;
import java.util.prefs.Preferences;

/**
 * ItemTracker.java
 * <p/>
 * Author:  Taw
 * Date:    4/20/14
 */
public class ItemTracker {

    public static final float VERSION=0.1f;

    public static Preferences prefs;

    public static IRCConnection connection;

    public ItemTracker () {
        prefs = Preferences.userRoot().node(this.getClass().getName());
    }



    public static JFrame frame;
    public static void main(String[] args){

        for(int i=0;i<Item.ITEMS.length;i++){
            Item item=Item.ITEMS[i];
            int j=i;
            while(j > 0 && (Item.ITEMS[j-1].toString().split(" ",2)[0].equals("a")||Item.ITEMS[j-1].toString().split(" ",2)[0].equals("the")?Item.ITEMS[j-1].toString().split(" ",2)[1]:Item.ITEMS[j-1].toString())  .compareTo(item.toString().split(" ",2)[0].equals("a")||item.toString().split(" ",2)[0].equals("the")?item.toString().split(" ",2)[1]:item.toString())>0){
                Item.ITEMS[j]=Item.ITEMS[j-1];
                j--;
            }
            Item.ITEMS[j]=item;
        }
        for(int i=0;i<Item.ITEMS.length;i++){
            Item.ITEMS[i].index=i;
        }


        EventBroker broker = new EventBroker();
        ItemPanel panel = new ItemPanel(broker);
        Inventory inventory = new Inventory(broker, panel);


        frame = new JFrame("BoI Item Inventory");
        frame.add(panel);
        //frame.add(new ConnectPanel());
        frame.setVisible(true);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(new Dimension(532,200));
    }



}
